import Mock from 'mockjs'

const lots = Mock.mock({
  'list|20': [{
    'id|+1': 1,
    name: '@ctitle(10, 20)',
    num: '@natural(0, 990)',
    time: [1537416000000, 1537488000000]
  }],
  total: 88
})

const sublots = Mock.mock({
  'list|1-20': [{
    'id|+1': 1,
    name: '@ctitle(10, 20)',
    num: '@natural(0, 990)',
    time: [1537416000000, 1603103894000],
    rate: 1.23,
    remark: '@ctitle(10, 20)',
    'cover|+1': ['http://lorempixel.com/350/350/', ''],
    show: '@boolean'
  }],
  mobile_qr: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1587441635,1276314476&fm=26&gp=0.jpg',
  total: 88
})

const lotInfo = Mock.mock({
  id: 1,
  name: '古龙会专场',
  state: '@natural(1, 1)',
  // [总件数，成交，流拍，未拍]
  num: [342, 67, 34, 128],
  deal: ['34430000', '82.48%'],
  'goods|50-100':[{
    'id|+1': 1,
    'lot|+1': 1,
    name: '@ctitle(5, 20)',
    'spec': [{ attr: '尺寸', val: 'H:7.8 D:9.6' }],
    cover: 'https://placeimg.com/320/200/nature/sepia',
    'state|+1': [1, 0, 1, 2, 2],
    curr: '@natural(100000000, 1000000000)',
    'curr_buyer|1': [0, '', '@natural(111, 999)'],
    start: '@natural(0, 10000)',
    'final|+1': ['', '', '10000', '流拍']
  }],
  'recent|3': [{
    lot: '@natural(111, 999)',
    'final|1': ['流拍', '10000'],
    'buyer_num|1': [0, '@natural(111, 999)'],
    'buyer_way|1': ['现场', '网络']
  }],
  bids: [{ num: 0, bid: '@natural(1000, 100000)' }],
  disRevoke: false,
  index: '@natural(0, 49)',
  livePush: {
    play: false,
    url: '',
    qr: ''
  },
  h5qr: ''
})

export default [
  {
    url: '/lot/getLots',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: process.env.VUE_APP_ROLE === 'sub' ? sublots : lots
      }
    }
  },
  {
    url: '/lot/getAllLots',
    type: 'get',
    response: config => {
      return {
        code: 200,
        'data|0-12': [{
          'id|+1': 1,
          name: '@ctitle(10, 20)'
        }]
      }
    }
  },
  {
    url: '/lot/setLot',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: sublots.list[0],
        msg: '专场信息修改成功'
      }
    }
  },
  {
    url: '/lot/delLot',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: { },
        msg: '删除成功'
      }
    }
  },
  {
    url: '/lot/emptyLot',
    type: 'post',
    response: config => {
      return {
        code: 200,
        data: { },
        msg: '清空成功'
      }
    }
  },
  {
    url: '/lot/getLotData',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: lotInfo
      }
    }
  },
  {
    url: '/lot/setLotState',
    type: 'post',
    response: config => {
      const { id, state } = config.body
      return {
        code: 200,
        data: { id: Number(id), state: Number(state) }
      }
    }
  },
  {
    url: '/lot/getAucingLots',
    type: 'get',
    response: config => {
      return {
        code: 200,
        'data|0-20': [{
          'id|+1': 1,
          name: '@ctitle(10, 20)'
        }]
      }
    }
  }
]